/**
 * 
 */
package com.net.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.net.domain.MarkDetails;

import com.net.web.form.MarksForm;

/**
 * @author Dinesh
 *
 */
public class MarkDao {
	final static Logger log = Logger.getLogger(StudentDao.class);
	
	private SqlMapClient sqlMapClient;

	public SqlMapClient getSqlMapClient() {
		return sqlMapClient;
	}

	@Autowired
	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}
	@SuppressWarnings("unchecked")
	public List<MarkDetails> getEligibleStudentsByGroupTest(MarksForm searchQuery) {
		List<MarkDetails> studentList = null;
		
		try {
			
			if(searchQuery.getSubjectClassGroupId() > 0)
				studentList = (List<MarkDetails>)sqlMapClient.queryForList("getEligibleStudentsByGroupTest", searchQuery);
			
		}
		catch (Exception e) {
			log.error("Error caught while retrieving Student details" + e.getMessage(), e);
		}
		
		return studentList;
	}
public void insertMarkDetails(List<MarkDetails> markList) {
		
		try {
			
			int count = 0;
			

			
			for(MarkDetails studentDetail : markList) {
				sqlMapClient.insert("insertMarkDetails", studentDetail);
			}
			
			log.info("Number of records written " + count);
			
		} catch (SQLException e) {
			log.error("Error caught while writing attendance details" + e.getMessage(), e);
		}
	}
public void insertTestDetails(List<MarkDetails> testList) {
	
	try {
		
			sqlMapClient.insert("insertTestDetails",testList);
		
		
		
		
	} catch (SQLException e) {
		log.error("Error caught while writing attendance details" + e.getMessage(), e);
	}
}

	
}
